package org.myspringmvc.web.servlet.view;

import lombok.Data;
import org.myspringmvc.web.servlet.View;
import org.myspringmvc.web.servlet.ViewResolver;

import java.util.Locale;

/**
 * @author 莫磊
 * @date 2025/8/12
 * @description 内部资源解析器，解析jsp
 */
@Data
public class InternalResourceViewResolver implements ViewResolver {

    private String prefix;

    private String suffix;

    private boolean flag;

    @Override
    public View resolveViewName(String viewName, Locale locale) throws Exception {

        // 根据对应的viewName进行解析，返回View对象
        InternalResourceView internalResourceView = new InternalResourceView();
        internalResourceView.setPath(prefix + viewName + suffix);
        return internalResourceView;
    }
}
